package wavenotes.model.preferences;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Text;

import wavenotes.model.presentation.Presentation;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserPreference {
	
	/**
	 * The fully qualified google wave account name (i.e. chrisdrobison@googlewave.com)
	 */
	@PrimaryKey
	private String name;
	
	/**
	 * The json array sent by the gadget. No server side modifications take place
	 */
	@Persistent
	private Text participantList;
	
	public UserPreference(String name, String participantList)
	{
		this.name = name;
		this.participantList = new Text(participantList);
	}
	
	public String getName()
	{
		return this.name;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	public String getParticipantList()
	{
		return this.participantList.getValue();
	}
	
	public void setParticipantList(String participantList)
	{
		this.participantList = new Text(participantList);
	}
	
	public static UserPreference getUserPreference(String user, PersistenceManager pm)
	{
		try { return pm.getObjectById(UserPreference.class, user); }
		catch(Exception ex_p) { return null; }
	}
}
